home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / html / util / genskunk.02 < prev    next >
Text File  |  1997-09-03  |  10KB  |  407 lines

  1. #! /usr/bin/perl -w 
  2.  
  3. $0 =~ s,.*/,,;
  4. $version="v1.1";
  5. $program=$0;
  6. $debug=0;
  7. $mailto='mailto:skunkware@sco.com';
  8. $baseref='http://www.sco.com/skunkware';
  9. $isweb=0;
  10.  
  11. sub usage {
  12.   warn "@_\n" if @_;
  13.   $! = 0;
  14.   die <<EOF;
  15. Usage: $0 -w | -c file name prev next
  16.   -w        - Generate pages for the Web
  17.   -c        - Generate pages for the CD-ROM
  18.   file      - name of the template (.tmpl) file
  19.   name      - the name of the package
  20.   prev      - the name of the previous link
  21.   next      - the name of the next link
  22.  
  23.   Use the word NONE for the prev and next parameters if the page doesnt
  24.   have a previous or next page in the document chain.
  25.  
  26. EOF
  27. }
  28.  
  29. if (@ARGV<1 || $#ARGV != 4) {
  30.   usage();
  31. }
  32.  
  33. $mode="0";
  34.  
  35. if($ARGV[0] eq "-w" || $ARGV[0] eq "web") {
  36.   $mode="SKUNK_WEB";
  37.   $isweb=1;
  38. }
  39. elsif($ARGV[0] eq "-c" || $ARGV[0] eq "cd") {
  40.   $mode="SKUNK_CD";
  41. }
  42.  
  43. if ($mode eq "0") {
  44.   usage();
  45. }
  46.  
  47. $now=`date '+%A %b %d, %Y at %T %Z'`; chop $now;
  48. $basefile=$ARGV[1];
  49. $shortname=$ARGV[2];
  50. $previous=$ARGV[3];
  51. $next=$ARGV[4];
  52. $realbase=`basename $basefile`; chop $realbase;
  53. #if ($isweb) {
  54. #  if (not -d $shortname) {
  55. #    mkdir($shortname,0755) or die "$program error: Could not create directory $shortname\n";
  56. #  }
  57. #  $output="$shortname/index.html";
  58. #} else {
  59.   $output="${realbase}.html";
  60. #}
  61. $template="${basefile}.tmpl";
  62. $templflt="/lib/cpp -I. -I.. -I../src -D$mode $template |";
  63.  
  64. -f $template or die "$program error: $template not found\n";
  65.  
  66. if ($debug) {
  67.  print "basefile : $basefile\n";
  68.  print "now      : $now\n";
  69.  print "shortname: $shortname\n";
  70.  print "previous : $previous\n";
  71.  print "next     : $next\n";
  72.  print "output   : $output\n";
  73.  print "realbase : $realbase\n";
  74.  print "template : $template\n";
  75. }
  76.  
  77. if ($previous eq "none" or $previous eq "NONE")
  78. {
  79.     $prevref="";
  80. } else {
  81.     if ($isweb) {
  82.         $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"\/skunkware\/$previous/index.html\">";
  83.     } else {
  84.         $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$previous.html\">";
  85.     }
  86. }
  87.  
  88. if ($next eq "none" or $next eq "NONE") {
  89.     $nextref="";
  90. } else {
  91.     if ($isweb) {
  92.         $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"\/skunkware\/$next/index.html\">";
  93.     } else {
  94.         $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$next.html\">";
  95.     }
  96. }
  97.  
  98. if ($debug) {
  99.  print "nextref=$nextref\n";
  100.  print "prevref=$prevref\n";
  101. }
  102.  
  103. open (TEMPLATE,$templflt) or die "$program error: cannot open $template for reading\n";
  104. open (OUTPUT,">$output") or die "$program error: cannot open $output for output\n";
  105.  
  106. sub skunkheader{
  107.     my($foo) = @_;
  108.     my($title,$plink,$nlink) = split(/;/,$foo);
  109.     my($oplink,$onlink);
  110.     if (not $plink) {
  111.         $oplink = $prevref;
  112.     } else {
  113.         if ($isweb) {
  114.             $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink/index.html\">";
  115.         } else {
  116.             $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink.html\">";
  117.         }
  118.     }
  119.     if (not $nlink) {
  120.         $onlink = $nextref;
  121.     } else {
  122.         if ($isweb) {
  123.             $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink/index.html\">";
  124.         } else {
  125.             $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink.html\">";
  126.         }
  127.     }
  128.  
  129.     if ($debug) {
  130.         print "skunkheader: title='$title'\n";
  131.         print "             oplink='$oplink'\n";
  132.         print "             onlink='$onlink'\n";
  133.     }
  134.  
  135.     if (not $title) {
  136.         warn "$program: No TITLE specified in SKUNKHEADER\n";
  137.     }
  138.  
  139.     if (not $isweb) {
  140. #
  141. # This is the header information for the Skunkware CD-ROM
  142. #
  143.         print OUTPUT <<EOF;
  144. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  145. <!-- DO NOT EDIT -->
  146. <!-- Automatically generated from $template by $program $version -->
  147. <!-- DO NOT EDIT -->
  148. <HTML>
  149. <HEAD>
  150.   <TITLE>$title</TITLE>
  151.   <LINK REV="made" HREF="$mailto">
  152. </HEAD>
  153. <BODY BGCOLOR="#ffffff">
  154.  
  155. <MAP NAME="skunknav">
  156.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$baseref/$shortname">
  157.   $oplink
  158.   $onlink
  159.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="index.html">
  160. </MAP>
  161.  
  162. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  163.   <TR ALIGN="LEFT" VALIGN="TOP">
  164.     <TD ROWSPAN="2" WIDTH="20%">
  165. <A HREF="http://www.sco.com/skunkware">
  166.       <IMG BORDER=0 SRC="gif/sk97s.gif" HEIGHT="104" WIDTH="108" ALIGN="BOTTOM">
  167. </A>
  168.     </TD>
  169.     <TD VALIGN="BOTTOM" WIDTH="79%">
  170.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  171.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  172.     </TD>
  173.   </TR>
  174.   <TR>
  175.     <TD VALIGN="TOP">
  176.       <IMG SRC="gif/${shortname}.gif" ALT="$title" HEIGHT="26" ALIGN="BOTTOM">
  177.     </TD>
  178.   </TR>
  179. </TABLE>
  180.  
  181. <H2 ALIGN="CENTER">Last Updated: $now</H2>
  182. EOF
  183.   } else {
  184. #
  185. # This is the header information for the Skunkware On-line pages
  186. #
  187.     print OUTPUT <<EOF;
  188. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  189. <!-- DO NOT EDIT -->
  190. <!-- Automatically generated from $template by $program $version -->
  191. <!-- DO NOT EDIT -->
  192. <HTML>
  193. <HEAD>
  194.   <TITLE>$title</TITLE>
  195.   <LINK REV="made" HREF="$mailto">
  196. </HEAD>
  197. <BODY BGCOLOR="#ffffff">
  198.  
  199. <MAP NAME="skunknav">
  200.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$baseref/$shortname">
  201.   $oplink
  202.   $onlink
  203.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="/skunkware/index.html">
  204. </MAP>
  205.  
  206. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  207.   <TR ALIGN="LEFT" VALIGN="TOP">
  208.     <TD ROWSPAN="2" WIDTH="20%">
  209. <A HREF="http://www.sco.com/skunkware">
  210.       <IMG BORDER=0 SRC="gif/sk97s.gif" HEIGHT="104" WIDTH="108" ALIGN="BOTTOM">
  211. </A>
  212.     </TD>
  213.     <TD VALIGN="BOTTOM" WIDTH="79%">
  214.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  215.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  216.     </TD>
  217.   </TR>
  218.   <TR>
  219.     <TD VALIGN="TOP">
  220.       <IMG SRC="gif/${shortname}.gif" ALT="$title" HEIGHT="26" ALIGN="BOTTOM">
  221.     </TD>
  222.   </TR>
  223. </TABLE>
  224.  
  225. <H2 ALIGN="CENTER">Last Updated: $now</H2>
  226. EOF
  227.   }
  228. }
  229.  
  230. sub skunkfooter {
  231.     my($foo) = @_;
  232.  
  233.     if ($isweb) {
  234. #
  235. # Print out the footer of a page for the On-line version of the page.
  236. # This should conform to the corporate guidelines.
  237. #
  238.         print OUTPUT <<EOF;
  239. <P><HR ALIGN=LEFT>
  240. <P> <FONT SIZE=-2>
  241. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  242. </FONT>
  243. </BODY>
  244. </HTML>
  245. EOF
  246.     } else {
  247. #
  248. # Print out the fotter for the CD-ROM version.
  249. #
  250.         print OUTPUT <<EOF;
  251. <P><HR ALIGN=LEFT>
  252. <P> <FONT SIZE=-2>
  253. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  254. </FONT>
  255. </BODY>
  256. </HTML>
  257. EOF
  258.     }
  259. }
  260.  
  261. sub start_packagelist {
  262.     my($foo) = @_;
  263.  
  264.     print OUTPUT <<EOF;
  265. <H2 ALIGN="CENTER">Package List</H2>
  266. <CENTER><TABLE WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  267.   <TR>
  268.     <TH WIDTH="11%" HEIGHT="23">Name</TH>
  269.     <TH WIDTH="62%">Description</TH>
  270.     <TH WIDTH="9%">Version</TH>
  271.     <TH WIDTH="7%">OSR5</TH>
  272.     <TH WIDTH="11%">UnixWare</TH>
  273.   </TR>
  274. EOF
  275. }
  276.  
  277. sub end_packagelist {
  278.     my($foo) = @_;
  279.  
  280.     print OUTPUT <<EOF;
  281. </TABLE></CENTER>
  282. <H4><HR ALIGN="LEFT"></H4>
  283. EOF
  284. }
  285.  
  286. sub startpack {
  287.     my($linkref,$desc) = @_;
  288.     print OUTPUT <<EOF;
  289. <H4><A NAME="$linkref"></A>$desc</H4>
  290. <BLOCKQUOTE>
  291. EOF
  292. }
  293.  
  294. sub endpack {
  295.     my($foo) = @_;
  296.  
  297.     print OUTPUT <<EOF;
  298. </BLOCKQUOTE>
  299. <P> </P>
  300. EOF
  301. }
  302.  
  303. sub source {
  304.     my($site) = @_;
  305.  
  306.     print OUTPUT <<EOF;
  307. <P>
  308. <A HREF="$site">
  309.   <IMG SRC="gif/origsrc.gif" ALT="Original source code" HSPACE="20" BORDER="0"
  310.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  311. <A HREF="$site">$site</A></P>
  312. EOF
  313. }
  314.  
  315. sub homepage {
  316.     my($page) = @_;
  317.  
  318.     print OUTPUT <<EOF;
  319. <P>
  320. <A HREF="$page">
  321.   <IMG SRC="gif/homepage.gif" ALT="Package Home page" HSPACE="20" BORDER="0"
  322.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  323. <A HREF="$page">$page</A></P>
  324. EOF
  325. }
  326.  
  327. sub osr5dist {
  328.     my($location) = @_;
  329.     my($volfile);
  330.     if ($location =~ /osr5\//) {
  331.         if (not $location =~ /\/$/) {
  332.             $location = "$location/";
  333.         }
  334.         $volfile="${location}VOLS.tar";
  335.         print OUTPUT <<EOF;
  336. <P><A HREF="$baseref/$volfile">
  337.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  338.   ALIGN="CENTER" ALT="OpenServer Distribution"></A>
  339. <A HREF="$baseref/$location">$location</A></P>
  340. EOF
  341.     } else {
  342.         print OUTPUT <<EOF;
  343. <P><A HREF="$location">
  344.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  345.   ALIGN="CENTER" ALT="OpenServer Distribution">
  346. $location
  347. </A></P>
  348. EOF
  349.     }
  350. }
  351.  
  352. sub uw2dist {
  353.     my($location) = @_;
  354.     my($volfile);
  355.     if ($location =~ /uw2\//) {
  356.         if (not $location =~ /\/$/) {
  357.             $location = "$location/";
  358.         }
  359.         print OUTPUT <<EOF;
  360. <P><A HREF="$baseref/$location">
  361.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  362.   ALIGN="CENTER" ALT="UnixWare Distribution"></A>
  363. <A HREF="$baseref/$location">$location</A></P>
  364. EOF
  365.     } else {
  366.         print OUTPUT <<EOF;
  367. <P><A HREF="$location">
  368.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  369.   ALIGN="CENTER" ALT="UnixWare Distribution">
  370. $location
  371. </A></P>
  372. EOF
  373.     }
  374. }
  375.  
  376. sub packlist{
  377.     my($foo) = @_;
  378.     my($linkref,$desc,$packver,$isosr5,$isuw2) = split(/;/, $foo);
  379.  
  380.     print OUTPUT <<EOF;
  381. <TR>
  382.   <TD><A HREF="#$linkref">$linkref</A></TD>
  383.   <TD>$desc</TD>
  384.   <TD>$packver</TD>
  385.   <TD ALIGN="CENTER">$isosr5</TD>
  386.   <TD ALIGN="CENTER">$isuw2</TD>
  387. </TR>
  388. EOF
  389. }
  390.  
  391. LINE: while (defined($line = <TEMPLATE>)) {
  392.     next LINE if $line =~ /^# [0-9]* \"/;
  393.     chop $line;
  394.     if ($line =~ s/@@\@SKUNKHEADER\((.*)\)//) { skunkheader($1);}
  395.     elsif ($line =~ s/@@\@SKUNKFOOTER//) { skunkfooter();}
  396.     elsif ($line =~ s/@@\@START_PACKAGELIST//) {start_packagelist();}
  397.     elsif ($line =~ s/@@\@END_PACKAGELIST//) {end_packagelist();}
  398.     elsif ($line =~ s/@@\@STARTPACK\((.*);(.*)\)//) {startpack($1,$2);}
  399.     elsif ($line =~ s/@@\@ENDPACK//) {endpack();}
  400.     elsif ($line =~ s/@@\@OSR5DIST\((.*)\)//) {osr5dist($1);}
  401.     elsif ($line =~ s/@@\@UW2DIST\((.*)\)//) {uw2dist($1);}
  402.     elsif ($line =~ s/@@\@SOURCE\((.*)\)//) {source($1);}
  403.     elsif ($line =~ s/@@\@HOMEPAGE\((.*)\)//) {homepage($1);}
  404.     elsif ($line =~ s/@@\@PACKLIST\((.*)\)//) {packlist($1);}
  405.     else {print OUTPUT "$line\n";}
  406. }
  407.